<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:poue="http://primefaces.org/ui/extensions">


    <ui:define name="content">

        <h:panelGroup rendered="true" >

            <h:form>
                <p:panel  id="panelPrint" header="Report by Referring Doctor">

                    <f:facet name="header" >

                        <p:outputLabel value="#{labels.company_name}"/>
                        <br/>
                        <p:outputLabel value="Report by Referring Doctor"/>
                        <p:commandButton value="Refresh" ajax="false"  styleClass="noPrintButton" style="float: right;" />

                        <p:commandButton ajax="false" value="Print"  styleClass="noPrintButton" style="float: right;" >
                            <p:printer target="panelPrint" />
                        </p:commandButton>

                        <p:commandButton ajax="false" value="Excel"  styleClass="noPrintButton" style="float: right;" >
                            <poue:exporter type="xlsx" target="tbl" fileName="Report By Referring Doctor"  />  
                        </p:commandButton>

                        <p:panelGrid columns="4" style="min-width:100%;">

                            <h:outputLabel value="From Date"/>
                            <p:calendar id="frmDate" value="#{commonReport.fromDate}" navigator="true"  pattern="dd MMMM yyyy HH:mm:ss" >
                            </p:calendar>

                            <h:outputLabel value="To Date"/>
                            <p:calendar id="toDate" value="#{commonReport.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss" >
                            </p:calendar>

                        </p:panelGrid>
                    </f:facet>

                    <p:dataTable id="tbl" value="#{commonReport.billsByReferingDoc}" var="d" >

                        <f:facet name="header">

                            <h:outputLabel value="Report by Referring Doctor From "/>
                            <p:outputLabel value="#{commonReport.fromDate}">
                                <f:convertDateTime pattern="dd MM yyyy"/>
                            </p:outputLabel>
                            <p:outputLabel value=" To "/>
                            <p:outputLabel value="#{commonReport.toDate}">
                                <f:convertDateTime pattern="dd MM yyyy"/>
                            </p:outputLabel>

                        </f:facet>

                        <p:column headerText="Referring Doctor">
                            <f:facet name="header">
                                <h:outputLabel value="Referring Doctor"/>
                            </f:facet>
                            <h:outputLabel value="#{d.referredBy.person.nameWithTitle}"/>
                        </p:column>

                        <p:column headerText="Bill Code" >
                            <f:facet name="header">
                                <h:outputLabel value="Bill Code"/>
                            </f:facet>
                            <h:outputLabel value="#{d.insId}"/>
                        </p:column>

                        <p:column headerText="To Department" >
                            <f:facet name="header">
                                <h:outputLabel value="To department"/>
                            </f:facet>
                            <h:outputLabel value="#{d.toDepartment.name}"/>
                        </p:column>

                        <p:column headerText="Cancel or Not" >
                            <f:facet name="header">
                                <h:outputLabel value="Cancel or Not"/>
                            </f:facet>
                            <h:outputLabel rendered="#{d.cancelled}" value="Cancelled"/>
                        </p:column>

                        <p:column headerText="Refunded or Not"  >
                            <f:facet name="header">
                                <h:outputLabel value="Refunded or Not"/>
                            </f:facet>
                            <h:outputLabel rendered="#{d.refunded}" value="Refunded"/>
                        </p:column>

                        <p:column headerText="Discount" style="text-align: right;">
                            <f:facet name="header">
                                <h:outputLabel value="Discount"/>
                            </f:facet>
                            <h:outputLabel value="#{d.discount}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column> 

                        <p:column headerText="Net Total" style="text-align: right;" >
                            <f:facet name="header">
                                <h:outputLabel value="Net Total"/>
                            </f:facet>
                            <h:outputLabel value="#{d.netTotal}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column>

                    </p:dataTable>

                </p:panel>        
            </h:form>
        </h:panelGroup>
    </ui:define>

</ui:composition>
